package com.ruoyi.web.controller.test;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.web.controller.kafka.KafkaProducer;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description:
 * @Author: LJ
 * @Date: 2022/9/23 11:17
 * @version:
 */
@Api(tags = "kafka测试类")
@RestController
@RequestMapping("/kafka")
public class KafkaController {
    @Autowired
    private KafkaProducer kafkaProducer;

    //@Anonymous
    @ApiOperation("测试发送消息")
    @GetMapping("/send")
    public AjaxResult send(@RequestParam @ApiParam("发送内容") String message) {
        TestKafka testKafka =new TestKafka();
        testKafka.setMessage(message);
        kafkaProducer.send(testKafka);
        return AjaxResult.success();
    }
}
